<style scoped>
.div_main{
  position: relative !important;
  background: transparent;
  padding-top: 10px;
  padding-left: 10px;
  padding-right: 10px;
  overflow-y: scroll;
  height:calc(100% - 30px);
  /*border: 1px red solid;*/
}
.div_main::-webkit-scrollbar { width: 0; height: 0; }

.m_div_container{
  height: calc(100% - 40px);
  overflow: scroll;
  /*border: 1px red solid;*/
}
.m_div_container::-webkit-scrollbar { width: 0; height: 0; }
.div_card{
  margin-top: 10px;
  padding: 5px;
  background-color: #ffffff;
  border-radius: 5px;
  box-shadow: 0px 0px 2px rgba(0,37,57,0.2);
}
.div_card_title{
  padding-left: 5px;
  padding-top: 3px;
  padding-bottom: 5px;
  font-size: 16px;
  color: #666666;
  padding-bottom: 5px;
  border-bottom: 1px #CCCCCC solid;
}
.div_card_body{
  padding-left: 5px;
  padding-right: 5px;
  padding-bottom: 5px;
}
.div_card_item{
  width: 100%;
  font-size: 16px;
  color: #666666;
  padding-top: 12px;
  /*border: 1px red solid;*/
}
</style>
<template>
  <div class="div_main">
    <div style="font-size: 1.6rem;margin-top: -8px;color: #ffffff;padding-bottom: 5px;" >
      <van-icon name="arrow-left" @click="$router.push({ path: '/business/my/s_menu' })" />
    </div>
    <div class="m_div_container">
      <div v-for="item in dataList" class="div_card">
        <div class="div_card_title">{{item.title}}</div>
        <div class="div_card_body">
          <template v-for="sItem in item.list">
            <div class="div_card_item">
              <div v-if="sItem.type=='text'">
                {{sItem.title}}：
                {{sItem.content}}
              </div>
              <div v-if="sItem.type=='text_list'">
                <div v-if="sItem.title!=null" style="margin-bottom: 5px;">{{sItem.title}}：</div>
                <div v-for="text in sItem.content"
                     style="margin-left: 5px;margin-right: 5px;border-bottom: 1px #CCCCCC dashed;padding: 3px;">{{text}}</div>
              </div>
            </div>
          </template>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      loading: false,
      dataList:{},
    }
  },
  mounted() {

    this.v_getData();
  },
  methods: {
    async v_getData(){
      let basicData = await elm.post('/business/my/GetEIBasic');

      let orgs = await elm.post('/business/my/ei/GetOrgs', {"ei_id": basicData.id });
      let orgList= [];
      for(let i=0;i<orgs.length;i++){
        let oo = orgs[i];
        let text = oo.name;
        if(oo.fzr==1){text = text+'|负责人'}
        if(oo.pm==1){text = text+'|主部门'}
        orgList.push(text);
      }
      orgs = orgList;
      let phones=this.em(basicData.phone) ?[]:basicData.phone.split(",");
      phones=phones.join(',');

      this.dataList = [
        {
          'title':'基础信息',
          list:[
            {'type':'text','title':'工号','content':basicData.emp_code},
            {'type':'text','title':'姓名','content':basicData.name},
            {'type':'text_list','title':'所在部门','content':orgs},
            {'type':'text','title':'性别','content':basicData.sex},
            {'type':'text','title':'民族','content':basicData.nation},
            {'type':'text','title':'身份证号','content':basicData.id_card},
            {'type':'text','title':'出生日期','content':basicData.birthday},
            {'type':'text','title':'联系电话','content':phones},
            {'type':'text','title':'家庭住址','content':basicData.home_address},
            {'type':'text','title':'婚姻状况','content':basicData.marital_status},
            {'type':'text','title':'政治面貌','content':basicData.politics_status},
            {'type':'text','title':'用工状态','content':basicData.work_status},
            {'type':'text','title':'入职时间','content':basicData.enter_company_date},
            {'type':'text','title':'参加工作时间','content':basicData.work_date},
            {'type':'text','title':'学历','content':basicData.education},
            {'type':'text','title':'备注','content':basicData.remark},
          ],
        },
      ];


      let extend_个人技能=await elm.post('/business/my/ei/extend/GetData', {"ei_id": basicData.id,type:'个人技能' });
      let extend_曾获荣誉=await elm.post('/business/my/ei/extend/GetData', {"ei_id": basicData.id,type:'曾获荣誉' });
      let career_教育背景=await elm.post('/business/my/ei/career/GetData', {"ei_id": basicData.id,type:'教育背景' });
      let career_过往工作=await elm.post('/business/my/ei/career/GetData', {"ei_id": basicData.id,type:'过往工作' });
      let credentials_资格证书 = await elm.post('/business/my/ei/credentials/GetData', {"ei_id": basicData.id,type:'资格证书' });
      let credentials_专业职称 = await elm.post('/business/my/ei/credentials/GetData', {"ei_id": basicData.id,type:'专业职称' });

      let extend_grjn = [];
      for(let i=0;i<extend_个人技能.length;i++){
        let item = extend_个人技能[i];
        extend_grjn.push(item.text);
      }
      this.dataList.push(
          {'title':'个人技能',
            list:[
              {'type':'text_list','title':null,'content':extend_grjn},
            ],
          },
      );
      if(career_教育背景.length>0){
        for(let i=0;i<career_教育背景.length;i++){
          let career_item = career_教育背景[i];
          this.dataList.push(
              {'title':'教育背景',
                list:[
                  {'type':'text','title':'开始日期','content':career_item.sdate},
                  {'type':'text','title':'结束日期','content':career_item.edate},
                  {'type':'text','title':'学校名称','content':career_item.org},
                  {'type':'text','title':'学习专业','content':career_item.major},
                  {'type':'text','title':'学历','content':career_item.diploma},
                  {'type':'text','title':'备注','content':career_item.remark},
                  {'type':'text','title':'主修课程','content':career_item.results},
                ],
              },
          );
        }
      }
      if(career_过往工作.length>0){
        for(let i=0;i<career_过往工作.length;i++){
          let career_item = career_过往工作[i];
          this.dataList.push(
              {'title':'过往工作',
                list:[
                  {'type':'text','title':'开始日期','content':career_item.sdate},
                  {'type':'text','title':'结束日期','content':career_item.edate},
                  {'type':'text','title':'工作单位','content':career_item.org},
                  {'type':'text','title':'担任职务','content':career_item.major},
                  {'type':'text','title':'主要业绩','content':career_item.results},
                ],
              },
          );
        }
      }
      let extend_chry = [];
      for(let i=0;i<extend_曾获荣誉.length;i++){
        let item = extend_曾获荣誉[i];
        extend_chry.push(item.text);
      }
      this.dataList.push(
          {'title':'曾获荣誉',
            list:[
              {'type':'text_list','title':null,'content':extend_chry},
            ],
          },
      );
      if(credentials_资格证书.length>0){
        for(let i=0;i<credentials_资格证书.length;i++){
          let cItem = credentials_资格证书[i];
          this.dataList.push(
              {'title':'资格证书',
                list:[
                  {'type':'text','title':'证书名称','content':cItem.name},
                  {'type':'text','title':'编号','content':cItem.cred_key},
                  {'type':'text','title':'发证机构','content':cItem.cred_org},
                  {'type':'text','title':'签发日期','content':cItem.cred_date},
                  {'type':'text','title':'起始有效期','content':cItem.valid_sdate},
                  {'type':'text','title':'截止有效期','content':cItem.valid_edate},
                ],
              },
          );
        }
      }
      if(credentials_专业职称.length>0){
        for(let i=0;i<credentials_专业职称.length;i++){
          let cItem = credentials_专业职称[i];
          this.dataList.push(
              {'title':'专业职称',
                list:[
                  {'type':'text','title':'职称名称','content':cItem.name},
                  {'type':'text','title':'编号','content':cItem.cred_key},
                  {'type':'text','title':'发证机构','content':cItem.cred_org},
                  {'type':'text','title':'签发日期','content':cItem.cred_date},
                  {'type':'text','title':'起始有效期','content':cItem.valid_sdate},
                  {'type':'text','title':'截止有效期','content':cItem.valid_edate},
                  {'type':'text','title':'专业','content':cItem.major},
                  {'type':'text','title':'备注','content':cItem.remark},
                ],
              },
          );
        }
      }
    },

    em: function (s) {
      if (s == null || s == '') { return true; }
      else { return false; }
    },

  }
}
</script>
